package com.hgy.sort;

import java.text.SimpleDateFormat;
import java.util.Date;

public class SelectSort {
    public static void main(String[] args) {
        int num = 80000;
        int arr[] = new int[num];
        for (int i = 0; i < num; i++) {
            arr[i] = (int)(Math.random() * num);
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1 = new Date();
        String d1str = simpleDateFormat.format(d1);
        System.out.println(d1str);

        selectSort(arr);

        Date d2 = new Date();
        String d2str = simpleDateFormat.format(d2);
        System.out.println(d2str);
    }

    public static void selectSort(int[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            int min = arr[i];
            int index = i;
            for (int j = i+1; j < arr.length; j++) {
                if (arr[j] < min) {
                    min = arr[j];
                    index = j;
                }
            }
            if (index != i) {
                arr[index] = arr[i];
                arr[i] = min;
            }
        }
    }
}
